package com.zch.mobile;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.common.excel.ExcelException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.base.dialect.PaginationSupport;
import com.base.mobile.MobException;
import com.base.mobile.MobileInfo;
import com.base.mobile.server.annotation.Mobile;
import com.base.mobile.server.annotation.MobileMethod;
import com.base.util.DateUtil;
import com.bf.common.proto.MZhiku;
import com.bf.common.proto.MAbility.AbilityDetail;
import com.bf.common.proto.MAbility.AbilityDetailList;
import com.bf.common.proto.MActivity.ActivityTypedetail;
import com.bf.common.proto.MActivity.ActivityTypedetailList;
import com.bf.common.proto.MActivity.Activitydetail;
import com.bf.common.proto.MActivity.ActivitydetailList;
import com.bf.common.proto.MActivity.MyActivityDetail;
import com.bf.common.proto.MActivity.MyActivityList;
import com.bf.common.proto.MApplyProject.ApplyProjectDetail;
import com.bf.common.proto.MApplyProject.ApplyProjectList;
import com.bf.common.proto.MBank.BankDetail;
import com.bf.common.proto.MBank.BankList;
import com.bf.common.proto.MCollegeMessage.CollegeMessagedetail;
import com.bf.common.proto.MCollegeMessage.CollegeMessagedetailList;
import com.bf.common.proto.MCommon.MRet;
import com.bf.common.proto.MCompanyRegister.CompanyRegisterdetail;
import com.bf.common.proto.MCompanyRegister.CompanyRegisterdetailList;
import com.bf.common.proto.MCompanyRegisterNew.CompanyRegisterNewdetail;
import com.bf.common.proto.MCompanyRegisterNew.CompanyRegisterNewdetailList;
import com.bf.common.proto.MDept.Deptdetail;
import com.bf.common.proto.MDept.DeptdetailList;
import com.bf.common.proto.MFindMsg.FindMsg;
import com.bf.common.proto.MFindMsg.FindMsgList;
import com.bf.common.proto.MFindMsg.Meeting;
import com.bf.common.proto.MFindMsg.MeetingJoinUser;
import com.bf.common.proto.MFindMsg.MeetingJoinUserList;
import com.bf.common.proto.MFindMsg.MeetingList;
import com.bf.common.proto.MIndex.Indexdetial;
import com.bf.common.proto.MIndex.IndexdetialList;
import com.bf.common.proto.MPolicyInfo.Policydetail;
import com.bf.common.proto.MPolicyInfo.PolicydetailList;
import com.bf.common.proto.MProjectFollow.ProjectFollowdetail;
import com.bf.common.proto.MProjectFollow.ProjectFollowdetailList;
import com.bf.common.proto.MProjectMsgList.ProjectMsgDetail;
import com.bf.common.proto.MProjectMsgList.ProjectMsgDetailList;
import com.bf.common.proto.MProjectMsgList.ProjectMsgTotal;
import com.bf.common.proto.MSendProject.CyTypedetail;
import com.bf.common.proto.MSendProject.CyTypedetailList;
import com.bf.common.proto.MSendProjectAnalyze.SendProjectAnalyzedetail;
import com.bf.common.proto.MSendProjectConnect.SendProjectConnectdetail;
import com.bf.common.proto.MSendProjectConnect.SendProjectConnectdetailList;
import com.bf.common.proto.MServiceOrganization.ServiceOrganizationDetail;
import com.bf.common.proto.MServiceOrganization.ServiceOrganizationList;
import com.bf.common.proto.MTeamWorkWay.TeamWorkWaydetail;
import com.bf.common.proto.MTeamWorkWay.TeamWorkWaydetailList;
import com.bf.common.proto.MTechnologymessage.Technologymessagedetail;
import com.bf.common.proto.MTechnologymessage.TechnologymessagedetailList;
import com.bf.common.proto.MTrade.Tradedetail;
import com.bf.common.proto.MTrade.TradedetailList;
import com.bf.common.proto.MXqmessage.ServiceTypeDetail;
import com.bf.common.proto.MXqmessage.ServiceTypeList;
import com.bf.common.proto.MXqmessage.Xqmessagedetail;
import com.bf.common.proto.MXqmessage.XqmessagedetailList;
import com.bf.common.proto.MZaiti.ZaitiType;
import com.bf.common.proto.MZaiti.ZaitiTypeList;
import com.bf.common.proto.MZaiti.Zaitidetail;
import com.bf.common.proto.MZaiti.ZaitidetailList;
import com.bf.common.proto.MZxMessage.ZxMessagedetail;
import com.bf.common.proto.MZxMessage.ZxMessagedetailList;
import com.fasterxml.jackson.databind.ObjectWriter.GeneratorSettings;
import com.item.dao.model.User;
import com.item.dao.model.UserNotify;
import com.item.service.UserNotifyService;
import com.item.service.UserService;
import com.zch.dao.model.Ability;
import com.zch.dao.model.AbilityExample;
import com.zch.dao.model.ActIsReadLog;
import com.zch.dao.model.ActIsReadLogExample;
import com.zch.dao.model.Activitymessage;
import com.zch.dao.model.ActivitymessageExample;
import com.zch.dao.model.ApplyProject;
import com.zch.dao.model.ApplyProjectExample;
import com.zch.dao.model.Bank;
import com.zch.dao.model.BankExample;
import com.zch.dao.model.Collegemessage;
import com.zch.dao.model.CollegemessageExample;
import com.zch.dao.model.CompanyRegister;
import com.zch.dao.model.CompanyRegisterExample;
import com.zch.dao.model.CompanyRegisterNew;
import com.zch.dao.model.CompanyRegisterNewExample;
import com.zch.dao.model.Dept;
import com.zch.dao.model.DeptExample;
import com.zch.dao.model.MeetingExample;
import com.zch.dao.model.MeetingJoinUserExample;
import com.zch.dao.model.Policy;
import com.zch.dao.model.PolicyExample;
import com.zch.dao.model.PolicyExample.Criteria;
import com.zch.dao.model.Principal;
import com.zch.dao.model.PrincipalExample;
import com.zch.dao.model.ProjectAnalyzeExample;
import com.zch.dao.model.ProjectMessage;
import com.zch.dao.model.ServiceOrganization;
import com.zch.dao.model.ServiceOrganizationExample;
import com.zch.dao.model.ServiceType;
import com.zch.dao.model.Technologymessage;
import com.zch.dao.model.TechnologymessageExample;
import com.zch.dao.model.MyActivity;
import com.zch.dao.model.MyActivityExample;
import com.zch.dao.model.Zaiti;
import com.zch.dao.model.ZxMessage;
import com.zch.dao.model.ZxMessageExample;
import com.zch.daoEx.model.ActIsReadLogEx;
import com.zch.daoEx.model.ActivitymessageEx;
import com.zch.daoEx.model.ActivitytypeEx;
import com.zch.daoEx.model.CollegemessageEx;
import com.zch.daoEx.model.CompanyRegisterEx;
import com.zch.daoEx.model.CompanyRegisterNewEx;
import com.zch.daoEx.model.CyTypeEx;
import com.zch.daoEx.model.DeptEx;
import com.zch.daoEx.model.IndexNews;
import com.zch.daoEx.model.ManagerFollowEx;
import com.zch.daoEx.model.MyActivityEx;
import com.zch.daoEx.model.PolicyEx;
import com.zch.daoEx.model.PrincipalEx;
import com.zch.daoEx.model.ProjectAnalyzeEx;
import com.zch.daoEx.model.ProjectConnectEx;
import com.zch.daoEx.model.ProjectMessageEx;
import com.zch.daoEx.model.TeamWorkWayEx;
import com.zch.daoEx.model.TechnologymessageEx;
import com.zch.daoEx.model.TradeEx;
import com.zch.daoEx.model.XqmessageEx;
import com.zch.daoEx.model.ZaitiEx;
import com.zch.daoEx.model.ZaitiTypeEx;
import com.zch.daoEx.model.ZhikuTypeEx;
import com.zch.daoEx.model.ZxMessageEx;
import com.zch.service.AbilityService;
import com.zch.service.ActIsReadLogService;
import com.zch.service.ActivitymessageService;
import com.zch.service.ActivitytypeService;
import com.zch.service.ApplyProjectService;
import com.zch.service.BankService;
import com.zch.service.CollegemessageService;
import com.zch.service.CompanyRegisterNewService;
import com.zch.service.CompanyRegisterService;
import com.zch.service.CyTypeService;
import com.zch.service.DeptService;
import com.zch.service.ManagerFollowService;
import com.zch.service.MeetingJoinUserService;
import com.zch.service.MeetingService;
import com.zch.service.MyActivityService;
import com.zch.service.PolicyService;
import com.zch.service.PrincipalService;
import com.zch.service.ProjectAnalyzeService;
import com.zch.service.ProjectConnectService;
import com.zch.service.ProjectMessageService;
import com.zch.service.ServiceOrganizationService;
import com.zch.service.ServiceTypeService;
import com.zch.service.TeamWorkWayService;
import com.zch.service.TechnologymessageService;
import com.zch.service.TradeService;
import com.zch.service.XqmessageService;
import com.zch.service.ZaitiService;
import com.zch.service.ZaitiTypeService;
import com.zch.service.ZxMessageService;

import ch.qos.logback.core.util.DatePatternToRegexUtil;
import cn.weibo.org.json.JSONArray;
import tk.mybatis.mapper.entity.Example;
@Mobile
@Component
public class MInfo {
	@Autowired
	private ZaitiService zaitiService;
	@Autowired
	private ZxMessageService zxMessageService;
	@Autowired
	private TechnologymessageService technologymessageService;
	@Autowired
	private XqmessageService xqmessageService;
	@Autowired
    private CollegemessageService collegemessageService;
	@Autowired
    private DeptService deptService;
	@Autowired
    private TradeService tradeService;
	@Autowired
    private TeamWorkWayService teamWorkWayService;
	@Autowired
    private ActivitytypeService activitytypeService;
	@Autowired
    private ZaitiTypeService zaitiTypeService;
	@Autowired
    private CyTypeService cyTypeService;
	@Autowired
    private ProjectMessageService projectMessageService;
	@Autowired
    private UserService userService;
    @Autowired
    private PrincipalService principalService;
    @Autowired
    private ProjectAnalyzeService projectAnalyzeService;
    @Autowired
    private ProjectConnectService projectConnectService;
    @Autowired
    private CompanyRegisterService companyRegisterService;
    @Autowired
    private ManagerFollowService managerFollowService;
    @Autowired
    private ActivitymessageService activitymessageService;
    @Autowired
    private ServiceTypeService serviceTypeService;
    @Autowired
    private UserNotifyService userNotifyService;
    @Autowired
    private PolicyService policyService;
    @Autowired
    private MyActivityService myActivityService;
    @Autowired
    private MeetingService meetingService;
    @Autowired
    private MeetingJoinUserService meetingJoinUserService;
    @Autowired
    private CompanyRegisterNewService companyRegisterNewService;
    @Autowired
    private AbilityService abilityService;
    @Autowired
    private ServiceOrganizationService serviceOrganizationService;
    @Autowired
    private ApplyProjectService applyProjectService;
    @Autowired
    private BankService bankService;
    @Autowired
    private ActIsReadLogService actIsReadLogService;
	/**
	 * 载体列表
	 * 
	 * @param mobileInfo
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MZaitiList", isLogin = false, isPage = true)
	public ZaitidetailList.Builder zaitiList(MobileInfo mobileInfo,
                                	         Integer page, 
                                	         Integer limit, 
                                	         String name,
                                	         String zaitiType)
			throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", name);
		map.put("zaitiType", zaitiType);
		PaginationSupport.byPage(page, limit, false);
		List<ZaitiEx> list = zaitiService.selectAppList(map);

		ZaitidetailList.Builder ret = ZaitidetailList.newBuilder();
		for (ZaitiEx ex : list) {
			Zaitidetail.Builder c = Zaitidetail.newBuilder();
			c.setId(ex.getId());
			c.setZaitiName(ex.getZaitiName());
			c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
			c.setIsAgree(ex.getIsAgree().toString());
			c.setImage(ex.getImage());
			ret.addZaitis(c);
		}
		return ret;
	}

	/**
	 * 载体详情
	 * 
	 * @param mobileInfo
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MZaitiDetailList", isLogin = false)
	public Zaitidetail.Builder Zaitidetail(MobileInfo mobileInfo, String id)
			throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isBlank(id)) throw new MobException("id");
		map.put("id", id);
		ZaitiEx ex = zaitiService.selectAppDetailLists(map);

		if(ex == null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
		Zaitidetail.Builder c = Zaitidetail.newBuilder();
		c.setId(ex.getId());
		c.setZaitiName(ex.getZaitiName());
		c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
		c.setZaitiType(ex.getZaitiTypeName());
		c.setAddress(ex.getAddress());
		c.setArea(ex.getArea());
		c.setRental(ex.getRental().toString());
		c.setImage(ex.getImage());
		c.setContent(ex.getContent());
		c.setUserId(ex.getNickName());
		c.setIsAgree(ex.getIsAgree().toString());

		return c;
	}

	/**
	 * 资讯列表
	 * 
	 * @param mobileInfo
	 * @param parent
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MZxList", isLogin = false, isPage = true)
	public ZxMessagedetailList.Builder ZxMessagelList(MobileInfo mobileInfo,
			String parent,Integer page, Integer limit, String name, String cityName) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", name);
		map.put("cityName", cityName);
		PaginationSupport.byPage(page, limit, false);
		List<ZxMessageEx> list = zxMessageService.selectAppList(map);

		ZxMessagedetailList.Builder ret = ZxMessagedetailList.newBuilder();
		for (ZxMessageEx ex : list) {
			ZxMessagedetail.Builder c = ZxMessagedetail.newBuilder();
			c.setId(ex.getId());
			c.setIsAgree(ex.getIsAgree().toString());
			c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
			c.setZxTitle(ex.getZxTitle());
			c.setImage(ex.getImage());
			c.setType(ex.getType().toString());
			c.setContent(ex.getContent());
			ret.addZxMessagedetail(c);
		}
		return ret;
	}

	/**
	 * 资讯详情
	 * 
	 * @param mobileInfo
	 * @param parent
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MZxDetailList", isLogin = false)
	public ZxMessagedetail.Builder ZxMessagedetail(MobileInfo mobileInfo,
			String parent, String id) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isBlank(id)) throw new MobException("id");
		map.put("id", id);
		ZxMessageEx ex = zxMessageService.selectAppDetailList(map);

		if(ex == null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
		ZxMessagedetail.Builder c = ZxMessagedetail.newBuilder();
		c.setId(ex.getId());
		c.setContent(ex.getContent());
		c.setImage(ex.getImage());
		c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
		c.setZxTitle(ex.getZxTitle());
		c.setType(ex.getType().toString());
		c.setUserId(ex.getNickName());
		c.setCity(ex.getCity());
		c.setIsAgree(ex.getIsAgree().toString());
		return c;
	}
	
	/**
	 * 首页轮播
	 */
	@MobileMethod(methodno = "MIndexBanner", isLogin = false)
	public ZxMessagedetailList.Builder IndexBanner()throws Exception{
	    ZxMessagedetailList.Builder ret = ZxMessagedetailList.newBuilder();
	    ZxMessageExample example = new ZxMessageExample();
	    example.createCriteria().andIsIndexImageEqualTo(1).andIsAgreeEqualTo(1);
	    List<ZxMessage>	list = zxMessageService.selectByExample(example);
	    for(ZxMessage ex : list){
	        ZxMessagedetail.Builder c = ZxMessagedetail.newBuilder();
	        if(ex.getOnlyShowImage()==0){
	            
                c.setType(ex.getType().toString());
                
	        }else if(ex.getOnlyShowImage()==1){
	            c.setType(3+"");
	        }
	        c.setId(ex.getId());
            c.setImage(ex.getBannerImages());  
            c.setContent(ex.getContent());
            ret.addZxMessagedetail(c);
	    }
	    
	    return ret;
	}

	/**
	 * 技术发布列表
	 * 
	 * @param mobileInfo
	 * @param parent
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MtechnologyList", isLogin = false)
	public TechnologymessagedetailList.Builder TechnologymessagedetailList(
			MobileInfo mobileInfo, String tradeId) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("tradeId", tradeId);
		List<TechnologymessageEx> list = technologymessageService.selectAppList(map);

		TechnologymessagedetailList.Builder ret = TechnologymessagedetailList.newBuilder();
		for (TechnologymessageEx ex : list) {
			Technologymessagedetail.Builder c = Technologymessagedetail.newBuilder();
			c.setId(ex.getId());
			c.setTechnologyName(ex.getTechnologyName());
			c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
			ret.addTechnologymessagedetail(c);

		}
		return ret;
	}
	
	/**
	 * 技术发布详情
	 * @param mobileInfo
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MtechnologyDetail", isLogin = false)
	public Technologymessagedetail.Builder Technologymessagedetail(MobileInfo mobileInfo,
	                                                               String id)throws Exception{
	    if (StringUtils.isBlank(id)) throw new MobException("id");
	    Map<String, Object> map = new HashMap<String, Object>();
	    map.put("id", id);
	    TechnologymessageEx message = technologymessageService.selectDetail(map);
	    
	    if(message == null){
	        throw new MobException(MZchError.CONTENT_NOT_EXIST);
	    }
	    Technologymessagedetail.Builder c = Technologymessagedetail.newBuilder();
	    c.setId(message.getId());
	    c.setTechnologyName(message.getTechnologyName());
	    c.setDomainId(message.getTradeName());
	    c.setTeamworkWayId(message.getName());
	    c.setHavazl(message.getHavezl().toString());
	    c.setContent(message.getContent());
	    c.setArea(message.getArea());
	    c.setCreateTime(DateUtil.dateToStr(message.getCreateTime()));
	    c.setUserid(message.getNickName());
	    c.setPhone(message.getPhone());
	    return c;
	}
	

	/**
	 * 需求发布信息列表
	 * 
	 * @param mobileInfo
	 * @param parent
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MxqmessageList", isLogin = false ,isPage = true)
	public XqmessagedetailList.Builder XqmessageLists(MobileInfo mobileInfo,
			String parent,Integer page, Integer limit, String name, String trade_id) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("name", name);
		map.put("trade_id", trade_id);
		PaginationSupport.byPage(page, limit, false);
		List<XqmessageEx> list = xqmessageService.selectAppList(map);

		XqmessagedetailList.Builder ret = XqmessagedetailList.newBuilder();
		for (XqmessageEx ex : list) {
			Xqmessagedetail.Builder c = Xqmessagedetail.newBuilder();
			c.setId(ex.getId());
			c.setName(ex.getName());
			c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
			c.setIsAgree(ex.getIsAgree().toString());
			ret.addXqmessagedetail(c);
		}
		return ret;
	}

	/**
	 * 需求发布详情信息
	 * 
	 * @param mobileInfo
	 * @param parent
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MxqmessageDetailList", isLogin = false)
	public Xqmessagedetail.Builder Xqmessagedetail(MobileInfo mobileInfo,
			String parent, String id) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isBlank(id)) throw new MobException("id");
		map.put("id", id);
		XqmessageEx ex = xqmessageService.selectAppDetailList(map);

		if(ex == null){
            throw new MobException(MZchError.CONTENT_NOT_EXIST);
        }
		Xqmessagedetail.Builder c = Xqmessagedetail.newBuilder();
		c.setId(ex.getId());
		c.setName(ex.getName());
		c.setServiceType(ex.getServiceTypeName());
		c.setHavazl(ex.getHaveZl().toString());
		c.setMoney(ex.getMoney().toString());
		c.setCollege(ex.getCollege());
		c.setProfessor(ex.getProfessor());
		c.setContent(ex.getContent());
		c.setCompanyname(ex.getCompanyname());
		c.setProduct(ex.getProduct());
		c.setAddress(ex.getAddress());
		c.setManager(ex.getManager());
		c.setPhone(ex.getPhone());
		c.setDomainId(ex.getTradeName());
		c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
		c.setModifyTime(DateUtil.dateToStr(ex.getModifyTime()));
		c.setUserId(ex.getNickName());
		c.setIsAgree(ex.getIsAgree().toString());
		return c;
	}
	
	/**
	 * 高校发布列表
	 * @param mobileInfo
	 * @param parent
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MCollegeMessageList", isLogin = false)
	public CollegeMessagedetailList.Builder CollegeMessagedetailList(MobileInfo mobileInfo, String parent, String id)throws Exception {
	    Map<String, Object> map = new HashMap<String, Object>();
	    map.put("id", id);
	    List<CollegemessageEx> list = collegemessageService.selectListAppList(map);
	    
	    CollegeMessagedetailList.Builder ret = CollegeMessagedetailList.newBuilder();
	    for(CollegemessageEx ex : list){
	        CollegeMessagedetail.Builder c = CollegeMessagedetail.newBuilder();
	        c.setId(ex.getId());
	        c.setName(ex.getName());
	        c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
	        c.setModifyTime(DateUtil.dateToStr(ex.getModifyTime()));
	        ret.addCollegeMessagedetail(c);
	    }
	    return ret;
	}
	
	/**
	 * 高校发布详情信息
	 * @param mobileInfo
	 * @param parent
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@MobileMethod(methodno = "MCollegeMessageDetailList", isLogin = false)
	public CollegeMessagedetail.Builder CollegeMessagedetail(MobileInfo mobileInfo, String parent, String id)throws Exception {
	    Map<String, Object> map = new HashMap<String, Object>();
	    if (StringUtils.isBlank(id)) throw new MobException("id");
	    map.put("id", id);
	    CollegemessageEx ex = collegemessageService.selectAppDetailList(map);
	    if(ex == null){
	        throw new MobException(MZchError.CONTENT_NOT_EXIST);
	    }
	    CollegeMessagedetail.Builder c = CollegeMessagedetail.newBuilder();
	    c.setId(ex.getId());
	    c.setName(ex.getName());
	    c.setAddress(ex.getAddress());
	    c.setManager(ex.getManager());
	    c.setPhone(ex.getPhone());
	    c.setYssubject(ex.getYssubject());
	    c.setTecresult(ex.getTecresult());
	    c.setContent(ex.getContent());
	    c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
	    c.setModifyTime(DateUtil.dateToStr(ex.getModifyTime()));
	    c.setUserId(ex.getNickName());
	    return c;
	}
	
	/**
	 * 部门列表
	 * @param mobileInfo
	 * @return
	 * @throws Exception
	 */
   @MobileMethod(methodno = "MDeptList", isLogin = false)
   public DeptdetailList.Builder DeptdetailList(MobileInfo mobileInfo) throws Exception{
       Map<String, Object> map = new HashMap<String, Object>();
       List<DeptEx> list = deptService.selectList(map);
       
       DeptdetailList.Builder ret = DeptdetailList.newBuilder();
       
       // 找出大类
       List<DeptEx> mainTypes = findZhikuTypes(list, "0");
       for (DeptEx mainType: mainTypes)
       {
           Deptdetail.Builder mainBuilder = Deptdetail.newBuilder();
           mainBuilder.setDeptNo(mainType.getDeptNo());
           mainBuilder.setDeptName(mainType.getDeptName());
           
           // 找出小类
           List<DeptEx> childTypes = findZhikuTypes(list, mainType.getId());
           for (DeptEx childType : childTypes)
           {
               Deptdetail.Builder childBuilder = Deptdetail.newBuilder();
               childBuilder.setDeptNo(childType.getDeptNo());
               childBuilder.setDeptName(childType.getDeptName());
               mainBuilder.addDeptdetail(childBuilder);
           }
           
           ret.addDeptdetail(mainBuilder);
       }
       return ret;
   }
   
   /**
    * 找出指定parentId的
    * @param list
    * @param parentId
    * @return
    */
   private static List<DeptEx> findZhikuTypes(List<DeptEx> list, String parent)
   {
       List<DeptEx> results = new ArrayList<DeptEx>();
       for (DeptEx type : list)
       {
           if (type.getParent().equals(parent))
           {
               results.add(type);
           }
       }
       return results;
   }
   /**
    * 行业领域列表
    * @param mobileInfo
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MTradeList", isLogin = false)
   public TradedetailList.Builder TradedetailList(MobileInfo mobileInfo) throws Exception{
       List<TradeEx> list = tradeService.selectAppList();
       TradedetailList.Builder ret = TradedetailList.newBuilder();
       for(TradeEx ex : list){
           Tradedetail.Builder c = Tradedetail.newBuilder();
           c.setTradeName(ex.getTradeName());
           c.setTradeId(ex.getTradeId().toString());
           ret.addTradedetail(c);
       }
       return ret;
   }
   
   /**
    * 合作方式列表
    * @param mobileInfo
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MTeamWorkWayList", isLogin = false)
   public TeamWorkWaydetailList.Builder TeamWorkWaydetailList(MobileInfo mobileInfo) throws Exception{
       List<TeamWorkWayEx> list = teamWorkWayService.selectAppList();
       TeamWorkWaydetailList.Builder ret = TeamWorkWaydetailList.newBuilder();
       for(TeamWorkWayEx ex : list){
           TeamWorkWaydetail.Builder c = TeamWorkWaydetail.newBuilder();
           c.setId(ex.getId());
           c.setName(ex.getName());
           ret.addTeamWorkWaydetail(c);
       }
       return ret;
   }
   
   /**
    * 活动类型列表
    * @param mobileInfo
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MActivityTypeList", isLogin = false)
   public ActivityTypedetailList.Builder ActivityTypedetailList(MobileInfo mobileInfo) throws Exception{
       List<ActivitytypeEx> list = activitytypeService.selectAppList();
       ActivityTypedetailList.Builder ret = ActivityTypedetailList.newBuilder();
       for(ActivitytypeEx ex : list){
           ActivityTypedetail.Builder c = ActivityTypedetail.newBuilder();
           c.setId(ex.getId());
           c.setActivityTypeId(ex.getActivityTypeId());
           c.setActivityTypeName(ex.getActivityTypeName());
           ret.addActivityTypedetail(c);
       }
       return ret;
   }
   
   /**
    * 服务方式列表
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MServiceTypeList", isLogin = false)
   public ServiceTypeList.Builder ServiceTypeList()throws Exception{
       List<ServiceType> list = serviceTypeService.selectAppList();
       ServiceTypeList.Builder ret = ServiceTypeList.newBuilder();
       for(ServiceType ex : list){
           ServiceTypeDetail.Builder c = ServiceTypeDetail.newBuilder();
           c.setCode(ex.getServiceTypeId().toString());
           c.setName(ex.getServiceTypeName());
           c.setCreateTime(ex.getCreateTime().toString());
           ret.addServiceTypeDetail(c);
       }
       return ret;
   }
   
   /**
    * 载体类型列表
    * @param mobileInfo
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MZaitiTypeList", isLogin = false)
   public ZaitiTypeList.Builder ZaitiTypeList(MobileInfo mobileInfo) throws Exception{
       List<ZaitiTypeEx> list = zaitiTypeService.selectAppList();
       ZaitiTypeList.Builder ret = ZaitiTypeList.newBuilder();
       for(ZaitiTypeEx ex : list){
           ZaitiType.Builder c = ZaitiType.newBuilder();
           c.setCode(ex.getId());
           c.setName(ex.getZaitiTypeName());
           ret.addZaitiType(c);
           }
       return ret;
   }
   
   
   /**
    * 产业类型列表
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MCyTypeList", isLogin = false)
   public CyTypedetailList.Builder CyTypedetailList() throws Exception{
       
       List<CyTypeEx> list = cyTypeService.selectAppList();
       CyTypedetailList.Builder ret = CyTypedetailList.newBuilder();
       for(CyTypeEx ex : list){
           CyTypedetail.Builder c = CyTypedetail.newBuilder();
           c.setId(ex.getId());
           c.setCyTypeName(ex.getCyTypeName());
           ret.addCyTypedetail(c);
       }
       return ret;
   }
   
   
   /**
    * 项目发布列表
    * @param user_id 用户id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MProjectMsgList", isLogin = false, isPage = true)
   public ProjectMsgDetailList.Builder ProjectMsgDetailList(MobileInfo mobileInfo, Integer page, Integer limit)throws Exception{
       
       String user_id = mobileInfo.getUserid();
       User user = userService.selectByPrimaryKey(user_id);
       PaginationSupport.byPage(page, limit, false);
       List<ProjectMessageEx> lists = null;
       if(user != null){
           if(user.getType()==0){
               //普通用户
                 List<ProjectMessageEx> list= projectMessageService.selectAppListByNormal();
                 lists = list;
             }else if(user.getType()==1){
               //内部用户
                 List<ProjectMessageEx> list= projectMessageService.selectAppListByInside();
                 lists = list;
             }else if(user.getType()==2){
               //企业用户  
                 List<ProjectMessageEx> list= projectMessageService.selectAppListByNormal();
                 lists = list;
             }
       }else{
           List<ProjectMessageEx> list= projectMessageService.selectAppListByNormal();
           lists = list;
       }
       
       ProjectMsgDetailList.Builder ret = ProjectMsgDetailList.newBuilder();
       for(ProjectMessage ex: lists){
           ProjectMsgDetail.Builder c = ProjectMsgDetail.newBuilder();
           c.setId(ex.getId());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setTitle(ex.getTitle());
           c.setImage(ex.getImage());
           ret.addProjectMsgDetail(c);
       }
      
    return ret;
   }
   
   
   /**
    * 项目发布详情(普通用户)
    * @param id
    * @param user_id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MProjectMsgDetialByNormal", isLogin = false)
   public ProjectMsgDetail.Builder ProjectMsgDetialByNormal(String id,MobileInfo mobileInfo)throws Exception{
       if (StringUtils.isBlank(id)) throw new MobException("id");
       String user_id = mobileInfo.getUserid();
       User user = userService.selectByPrimaryKey(user_id);
       
       Map<String, Object> map = new HashMap<String, Object>();
       ProjectMessageEx result = null;
       if(user != null){
           if(user.getType()==0 || user.getType()==2){
               map.put("id", id);
               ProjectMessageEx projectMessage = projectMessageService.selectAppDetailByNormal(map);
               result = projectMessage;
           }
       }else{
           map.put("id", id);
           ProjectMessageEx projectMessage = projectMessageService.selectAppDetailByNormal(map);
           result = projectMessage;
       }
       
                     
       if(result==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       ProjectMsgDetail.Builder c = ProjectMsgDetail.newBuilder();
       c.setId(result.getId());
       c.setTitle(result.getTitle());
       c.setUser(result.getNickName());
       c.setCreateTime(DateUtil.dateToStr(result.getCreateTime()));
       c.setContent(result.getContent());
       c.setImage(result.getImage());
       c.setCompanyName(result.getCompanyName());
       c.setMaster(result.getMaster());
       c.setRegisterAddress(result.getAddress());
       c.setTotal(result.getTotal().toString());
       return c;
   }
   
/**
 * 项目发布详情(内部用户)
 * @param id
 * @return
 * @throws Exception
 */
   @MobileMethod(methodno = "MProjectMsgDetialByInside", isLogin = true)
   public ProjectMsgTotal.Builder ProjectMsgDetialByInside(String id, MobileInfo mobileInfo)throws Exception{
       if (StringUtils.isBlank(id)) throw new MobException("id");
       ProjectMsgTotal.Builder t = ProjectMsgTotal.newBuilder();
       String user_id = mobileInfo.getUserid();
       User user = userService.selectByPrimaryKey(user_id);
       Map<String, Object> map = new HashMap<String, Object>();
       ProjectMessageEx result = null;
       ProjectAnalyzeEx analyze = null;
       List<ProjectConnectEx> connect = null;
       CompanyRegisterEx register = null;
       List<ManagerFollowEx> follow =null;
       if(user.getType()==1){
           map.put("id", id);
           result = projectMessageService.selectAppDetailByInside(map);
           analyze = projectAnalyzeService.selectAppDetailByInside(map);
           connect = projectConnectService.selectAppDetailByInside(map);
           register = companyRegisterService.selectAppDetailByInside(map);
           follow = managerFollowService.selectAppDetailByInside(map);
       }       
       if(result==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       ProjectMsgDetail.Builder a = ProjectMsgDetail.newBuilder();
       a.setId(result.getId());
       a.setTitle(result.getTitle());
       a.setUser(result.getNickName());
       SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
       String dateString = sdf.format(new Date());
       a.setCreateTime(DateUtil.dateToStr(result.getCreateTime()));       
       a.setInvestor(result.getInvestor());
       a.setOperation(result.getOperation());
       a.setManager(result.getManager());
       a.setPhone(result.getPhone());
       a.setZaitiType(result.getZaitiTypeName());
       a.setCyType(result.getCyTypeName());
       a.setIsAgree(result.getIsAgree().toString());
       a.setArea(result.getArea());
       a.setContent(result.getProjectMsgContent());
       a.setProjectState(result.getProjectState().toString());
       a.setImage(result.getImage());
       a.setIsEnable(result.getIsEnable().toString());
       a.setProjectShutdownReason(result.getProjectShutdownReason());
       a.setNotAgreeReason(result.getNotAgreeReason());
       a.setTotal(result.getTotal().toString());
       a.setAnalyzeMaster(result.getAnalyzeMasterid());
       a.setConnectMaster(result.getConnectMasterid());
       a.setCompanyRegister(result.getRegisterMasterid());
       a.setFollowMaster(result.getFollowMasterid());
       t.setProjectMsgDetail(a);
       /*if(analyze == null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }*/
       if(analyze !=null){
                  
       SendProjectAnalyzedetail.Builder b = SendProjectAnalyzedetail.newBuilder();
       b.setId(analyze.getId());
       b.setConnectMaster(analyze.getNickName());
       b.setContent(analyze.getContent());
       b.setImage(analyze.getImage());
       b.setIsEnable(analyze.getIsEnable().toString());
       b.setCreateTime(DateUtil.dateToStr(analyze.getCreateTime()));
       t.setSendProjectAnalyzedetail(b);
       }
       /*if(connect == null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }*/
       if(connect!=null && connect.size()!=0){
           
       SendProjectConnectdetailList.Builder ret = SendProjectConnectdetailList.newBuilder();
       for(ProjectConnectEx ex : connect){
           SendProjectConnectdetail.Builder c = SendProjectConnectdetail.newBuilder();
           c.setId(ex.getId());
           c.setConnectCompany(ex.getConnectCompany());
           c.setJob(ex.getJob());
           c.setPhone(ex.getPhone());
           c.setContent(ex.getContent());
           c.setProjectConnectManager(ex.getNickName());
           c.setImage(ex.getImage());
           c.setIsEnable(ex.getIsEnable().toString());
           c.setType(ex.getType());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setProjectManager(ex.getProjectManager());
           ret.addSendProjectConnectdetail(c);
       }
       
       t.setSendProjectConnectdetailList(ret);
       }
       /*if(register == null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }*/
       if(register != null){
              
           CompanyRegisterdetail.Builder d = CompanyRegisterdetail.newBuilder();
           d.setId(register.getId());
           d.setRegisterName(register.getRegisterName());
           d.setCompanyName(register.getCompanyName());
           
           d.setAddress(register.getAddress());
           d.setRegisterMoney(register.getRegisterMoney().toString());
           d.setRegisterDate(DateUtil.dateToStr(register.getRegisterDate(), "yyyy-MM-dd"));
           d.setMaster(register.getMaster());
           d.setPhone(register.getPhone());
           d.setRanges(register.getRanges());
           d.setCreateTime(DateUtil.dateToStr(register.getCreateTime()));
           d.setIsEnable(register.getIsEnable().toString());
           d.setRegisterManager(register.getNickName());
           t.setCompanyRegisterdetail(d);
       }
       /*if(follow == null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }*/
       if(follow != null && follow.size()!=0){
       ProjectFollowdetailList.Builder ret = ProjectFollowdetailList.newBuilder();    
           for(ManagerFollowEx ex : follow){
               ProjectFollowdetail.Builder e = ProjectFollowdetail.newBuilder();
               e.setId(ex.getId());
               e.setFollowMaster(ex.getFollowMaster());
               e.setEmployNum(ex.getEmployNum());
               e.setIncome(ex.getIncome());
               e.setBeginDate(DateUtil.dateToStr(ex.getBeginDate()));
               e.setEndDate(DateUtil.dateToStr(ex.getEndDate()));
               e.setContent(ex.getContent());
               e.setResolveContent(ex.getResolveContent());
               e.setType(ex.getType().toString());
               e.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               e.setIsEnable(ex.getIsEnable().toString());
               ret.addProjectFollowdetail(e);          
           }
       t.setProjectFollowdetailList(ret);       
       }
       
       t.setProjectState(result.getProjectState().toString());

       
       
       return t;
   }
   
   /**
    * 1资讯2载体3技术供应4.技术需求5.高校发布6.政策 7.资本 8.活动
    * 首页列表
    * @param page
    * @param limit
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MIndexList", isLogin = false, isPage = true)
   public IndexdetialList.Builder IndexdetialList(MobileInfo mobileInfo, Integer page, Integer limit)throws Exception{
       PaginationSupport.byPage(page, limit, false);
       //初始化全部是未读
       int isRead = 0;
       //登录状态下
       Date now = new Date(); 
       if(null!=mobileInfo.getUserid()  && !"".equals(mobileInfo.getUserid())){
           Map<String, Object> map = new HashMap<String, Object>();
           map.put("userId", mobileInfo.getUserid());
           List<ActivitymessageEx> list = activitymessageService.selectIsRead(map);
           if(list.size()>0){
               isRead = 1;
               for(ActivitymessageEx ex: list){
                       if(now.getTime()-ex.getCreateTime().getTime() <= 86400000){
                           isRead = 0;
                       }                
               }
           }
           
       }else {
           Map<String, Object> map = new HashMap<String, Object>();
           List<ActivitymessageEx> list = activitymessageService.selectIsReads(map);
           if(list.size()>0){
               isRead = 1;
               for(ActivitymessageEx ex: list){
                   if(now.getTime()-ex.getCreateTime().getTime()<=86400000){
                       isRead = 0;
                       break;
                   }
               }
           }
       }
       List<IndexNews> principalList = zxMessageService.selectIndexNews();
       
       IndexdetialList.Builder ret = IndexdetialList.newBuilder();
       for(IndexNews ex : principalList){
           Indexdetial.Builder c = Indexdetial.newBuilder();
           c.setId(ex.getId());
           c.setTitle(ex.getTitle());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setType(ex.getType().toString());
           if(ex.getZxType()!=null){
               c.setCType(ex.getZxType().toString());
               c.setUrl(ex.getUrl());
           }        
           ret.addIndexdetial(c);
       }
       
       if(isRead == 0){
           //未读的
           ret.setIsRead("0");
       }else if(isRead == 1){
           //已读
           ret.setIsRead("1");
       }
       return ret;
   }
   
   /**
    * 项目跟踪详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MProjectFollowDetailList", isLogin = true)
   public ProjectFollowdetailList.Builder ProjectFollowdetailList(String id)throws Exception{
       Map<String, Object> map = new HashMap<String, Object>();
       if (StringUtils.isBlank(id)) throw new MobException("id");
       map.put("id", id);
       List<ManagerFollowEx> list = managerFollowService.selectAppDetailByInside(map);
       ProjectFollowdetailList.Builder ret = ProjectFollowdetailList.newBuilder();
       for(ManagerFollowEx ex : list){
           ProjectFollowdetail.Builder c = ProjectFollowdetail.newBuilder();
           c.setId(ex.getId());
           c.setFollowMaster(ex.getFollowMaster());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setEmployNum(ex.getEmployNum());
           c.setIncome(ex.getIncome());
           c.setContent(ex.getContent());
           c.setResolveContent(ex.getResolveContent());
           c.setType(ex.getType().toString());
           c.setBeginDate(DateUtil.dateToStr(ex.getBeginDate()));
           c.setEndDate(DateUtil.dateToStr(ex.getEndDate()));
           ret.addProjectFollowdetail(c);
       }
       
       return ret;
   }
   
   /**
    * 项目对接详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MprojectConnectDetailList", isLogin = false)
   public SendProjectConnectdetailList.Builder SendProjectConnectdetailList(MobileInfo mobileInfo, String id)throws Exception{
       Map<String, Object> map = new HashMap<String, Object>();
       if (StringUtils.isBlank(id)) throw new MobException("id");
       map.put("id", id);
       List<ProjectConnectEx> list = projectConnectService.selectAppDetailByInside(map);
       SendProjectConnectdetailList.Builder ret = SendProjectConnectdetailList.newBuilder();
       for(ProjectConnectEx ex : list){
           SendProjectConnectdetail.Builder c =SendProjectConnectdetail.newBuilder();
           c.setId(ex.getId());
           c.setConnectCompany(ex.getConnectCompany());
           c.setJob(ex.getJob());
           c.setPhone(ex.getPhone());
           c.setContent(ex.getContent());
           c.setProjectConnectManager(ex.getNickName());
           c.setImage(ex.getImage());
           c.setIsEnable(ex.getIsEnable().toString());
           c.setType(ex.getType());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setProjectManager(ex.getProjectManager());
           ret.addSendProjectConnectdetail(c);
       }
       
       ProjectMessage projectMessage = projectMessageService.selectByPrimaryKey(id);
       ProjectMsgTotal.Builder result = ProjectMsgTotal.newBuilder();
       
       if(projectMessage.getProjectState()>=2){
           if(list.size()>1){
               if(list.get(list.size()-1).getIsFinish()==1){
                   String zaitiCode = list.get(list.size()-1).getZaitiType();
                   Zaiti zaiti = zaitiService.selectByPrimaryKey(zaitiCode);
                   ret.setFinalZaiti(zaiti.getZaitiName());
               }
               
           }else if(list.size()==1){
               ret.setFinalZaiti("");
           }
           
           
           
       }
       ret.setShutDownReason(projectMessage.getProjectShutdownReason());
       ret.setProjectState(projectMessage.getProjectState().toString());
       ret.setIsConnectMaster("0");
       if(projectMessage.getConnectMaster().equals(mobileInfo.getUserid())){
           ret.setIsConnectMaster("1"); //是对接人
       }
       
       
       return ret;
   }
   
   /**
    * 活动列表
    * @param id
    * @param name
    * @param page
    * @param limit
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MActivitydetailList", isLogin = false, isPage = true)
   public ActivitydetailList.Builder ActivitydetailList(String id, String name, Integer page, Integer limit)throws Exception{
       Map<String, Object> map = new HashMap<String, Object>();       
       PaginationSupport.byPage(page, limit, false);
       map.put("id", id);
       map.put("name", name);
       List<ActivitymessageEx> list = activitymessageService.selectAppList(map);
       ActivitydetailList.Builder ret = ActivitydetailList.newBuilder();
       for(ActivitymessageEx ex : list){
           Activitydetail.Builder c = Activitydetail.newBuilder();
           c.setId(ex.getId());
           c.setActivityName(ex.getActivityName());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setImage(ex.getImage());
           c.setType(ex.getType()+"");
           c.setContent(ex.getContent());
           ret.addActivitydetail(c);
       }
       return ret;
   }
   
   /**
    * 活动详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MActivitydetail", isLogin = false)
   public Activitydetail.Builder Activitydetail(MobileInfo mobileInfo,String id)throws Exception{
       if (StringUtils.isBlank(id)) throw new MobException("id");
       if(mobileInfo.getUserid()!=null && mobileInfo.getUserid()!="" && mobileInfo.getUserid()!="null"){
           ActIsReadLog actIsReadLog = new ActIsReadLog();
           actIsReadLog.setIsRead(1);
           actIsReadLog.setUserId(mobileInfo.getUserid());
           actIsReadLog.setActId(id);
           ActIsReadLogExample example = new ActIsReadLogExample();
           example.createCriteria().andUserIdEqualTo(mobileInfo.getUserid()).andActIdEqualTo(id);
           List<ActIsReadLog> ex = actIsReadLogService.selectByExample(example);
           if(ex.size()==0){
               int result = actIsReadLogService.insert(actIsReadLog);
               if (result == 0){
                   throw new MobException(MZchError.SERVER_BUSY_ERROR);
               }
           }                      
       }
       
       Map<String ,Object> map = new HashMap<String, Object>();
       map.put("id", id);
       ActivitymessageEx ex = activitymessageService.selectDetail(map);
       Activitydetail.Builder c = Activitydetail.newBuilder();
       c.setActivityName(ex.getActivityName());
       c.setUser(ex.getNickName());
       c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
       c.setActivityType(ex.getActivityTypeName());
       c.setActivityTime(DateUtil.dateToStr(ex.getActivityTime()));
       c.setArea(ex.getArea());
       c.setContent(ex.getContent());
       c.setName(ex.getName());
       c.setCompany(ex.getCompany());
       c.setJob(ex.getJob());
       c.setZyly(ex.getZyly());
       c.setImage(ex.getImage());
       c.setIsAgree(ex.getIsAgree().toString());
       c.setName2(ex.getName2());
       c.setCompany2(ex.getCompany2());
       c.setJob2(ex.getJob2());
       c.setZyly2(ex.getZyly2());
       c.setName3(ex.getName3());
       c.setCompany3(ex.getCompany3());
       c.setJob3(ex.getJob3());
       c.setZyly3(ex.getZyly3());
       c.setType(ex.getType()+"");
       
       /*map.put("user_id", ex.getUserId());
       List<MyActivityEx> list = myActivityService.selectAppList(map);*/
       MyActivityExample example = new MyActivityExample();
       if(mobileInfo.getUserid()!=null){
           example.createCriteria().andActIdEqualTo(id).andUserIdEqualTo(mobileInfo.getUserid()); 
           List<MyActivity> list = myActivityService.selectByExample(example);
           if(list.size()!=0){
               c.setIsJoin("1");
           }else {
               c.setIsJoin("0");
           }
       }
       
       
       return c;
   }
   
   
   /**
    * 活动发布
    * @param mobileInfo
    * @param Acname
    * @param type
    * @param time
    * @param area
    * @param name
    * @param company
    * @param job
    * @param zyly
    * @param content
    * @param image
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MSendActivity", isLogin = true)
   public MRet.Builder SendActivity(MobileInfo mobileInfo,
                                                String Acname,
                                                String type,
                                                String time,
                                                String area,
                                                String name,
                                                String company,
                                                String job,
                                                String zyly,
                                                String content,
                                                String image,
                                                String name2,
                                                String company2,
                                                String job2,
                                                String zyly2,
                                                String name3,
                                                String company3,
                                                String job3,
                                                String zyly3,
                                                String ctype)throws Exception{
       MRet.Builder ret = MRet.newBuilder();
       Activitymessage activitymessage = new Activitymessage();
       if("0".equals(ctype)){
           //发布
           if (StringUtils.isBlank(Acname)) throw new MobException("Acname");
           if (StringUtils.isBlank(type)) throw new MobException("type");
           if (StringUtils.isBlank(time)) throw new MobException("time");
           if (StringUtils.isBlank(area)) throw new MobException("area");
           if (StringUtils.isBlank(name)) throw new MobException("name");
           if (StringUtils.isBlank(company)) throw new MobException("company");
           if (StringUtils.isBlank(job)) throw new MobException("job");
           if (StringUtils.isBlank(zyly)) throw new MobException("zyly");
           if (StringUtils.isBlank(content)) throw new MobException("content");           
           if(Acname.length()>=60){
               ret.setCode(-1);
               ret.setMsg("活动标题请控制在60个字以内...");
               return ret;
           }
           if(area.length()>=25){
               ret.setCode(-1);
               ret.setMsg("活动地点请控制在25个字以内...");
               return ret;
           }
           
           if(content.length() >= 1500){
               ret.setCode(-1);
               ret.setMsg("活动内容请控制在1500个字以内...");
               return ret;
           }
           activitymessage.setActivityName(Acname);
           activitymessage.setActivityTypeId(Integer.parseInt(type));
           SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
           Date activityTime = sdf.parse(time);
           activitymessage.setActivityTime(activityTime);
           activitymessage.setArea(area);
           activitymessage.setName(name);
           activitymessage.setCompany(company);
           activitymessage.setJob(job);
           activitymessage.setZyly(zyly);
           activitymessage.setContent(content);
           activitymessage.setImage(image);
           activitymessage.setIsAgree(0);
           activitymessage.setCreateTime(new Date());
           activitymessage.setUserId(mobileInfo.getUserid());
           activitymessage.setName2(name2);
           activitymessage.setCompany2(company2);
           activitymessage.setJob2(job2);
           activitymessage.setZyly2(zyly2);
           activitymessage.setName3(name3);
           activitymessage.setCompany3(company3);
           activitymessage.setJob3(job3);
           activitymessage.setZyly3(zyly3);
           activitymessage.setType(Integer.parseInt(ctype));
       }else if("1".equals(ctype)){
           //转载
           if (StringUtils.isBlank(Acname)) throw new MobException("Acname");
           if (StringUtils.isBlank(type)) throw new MobException("type");
           if (StringUtils.isBlank(content)) throw new MobException("content");
           if(Acname.length()>=60){
               ret.setCode(-1);
               ret.setMsg("活动标题请控制在60个字以内...");
               return ret;
           }
           activitymessage.setActivityName(Acname);
           activitymessage.setActivityTypeId(Integer.parseInt(type));
           activitymessage.setContent(content);
           activitymessage.setType(Integer.parseInt(ctype));
           activitymessage.setIsAgree(0);
           activitymessage.setUserId(mobileInfo.getUserid());
       }
       
       
       
       
       
       int result = activitymessageService.insert(activitymessage);
       if(result == 0){
           throw new MobException(MZchError.SERVER_BUSY_ERROR);
       }
       ret.setCode(1);
       return ret;
   }
   
   /**
    * name 输入的内容
    * type 类型(1资讯2技术需求3载体4资本5活动6政策10技术供应11高校12银行金融13项目申报14运营机构15法律服务16财会服务17知识产权18管理咨询19其它20人才项目)
    * code传入的搜索类型
    * @param name
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MFindMsg", isLogin = false)
   public FindMsgList.Builder  SearchMsg(String name, 
                                         String type,
                                         String code)throws Exception{
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("name", name);
       map.put("type", type);
       FindMsgList.Builder ret = FindMsgList.newBuilder();
       if(type.equals("1")){   
           List<ZxMessageEx> zxList = zxMessageService.selectAppList(map);
           
           for(ZxMessageEx ex : zxList){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getZxTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setImage(ex.getImage());
               c.setType(1+"");
               c.setContent(ex.getContent());
               c.setCtype(ex.getType().toString());
               ret.addFindMsg(c);
           }
       }else if(type.equals("2")){
           map.put("trade_id", code);
           List<XqmessageEx> xqList = xqmessageService.selectAppList(map);
           for(XqmessageEx ex : xqList){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getName());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(2+"");
               ret.addFindMsg(c);
           } 
       }else if(type.equals("3")){
           map.put("zaitiType", code);
           List<ZaitiEx> zaitiList = zaitiService.selectAppList(map);
           for(ZaitiEx ex : zaitiList){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getZaitiName());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setImage(ex.getImage());
               c.setType(3+"");
               ret.addFindMsg(c);
           }
       }else if(type.equals("4")){
           /*PrincipalExample example = new PrincipalExample();*/
           /*Criteria  criteria = example.createCriteria().andIsVerifyEqualTo(1);
           com.zch.dao.model.PrincipalExample.Criteria criteria = example.createCriteria().andIsVerifyEqualTo(1).andOrganizationNameLike("%"+name+"%");
           if(StringUtils.isNotBlank(name)){
               criteria.andRegistAddressLike("%"+name+"%");
               criteria.andRegistAddressLike("%"+name+"%");
           }   
           
           example.setOrderByClause("create_time desc");
           List<Principal> list = principalService.selectByExample(example);*/
           List<PrincipalEx> list = principalService.selectAppList(map);
           for(Principal ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getOrganizationInfo());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(4+"");
               ret.addFindMsg(c);
           }
       }else if(type.equals("5")){
           map.put("id", code);
           List<ActivitymessageEx> activityList = activitymessageService.selectAppList(map);
           for(ActivitymessageEx ex : activityList){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getActivityName());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setImage(ex.getImage());
               c.setType(5+"");
               c.setCtype(ex.getType()+"");
               c.setContent(ex.getContent());
               ret.addFindMsg(c);
           }
       }else if(type.equals("6")){
           PolicyExample example = new PolicyExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTitleLike("%"+name+"%");/*.andDeptnoEqualTo(Integer.parseInt(code));*/
           example.setOrderByClause("create_time desc");
           List<Policy> policyList = policyService.selectByExample(example);
           for(Policy ex : policyList){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(6+"");
               c.setCtype(ex.getType().toString());
               c.setContent(ex.getContent());
               ret.addFindMsg(c);
           }
       }else if(type.equals("10")){
           TechnologymessageExample example = new TechnologymessageExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTechnologyNameLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<Technologymessage> list = technologymessageService.selectByExample(example);
           for(Technologymessage ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTechnologyName());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(10+"");
               ret.addFindMsg(c);
           }
       }else if(type.equals("11")){
           CollegemessageExample example = new CollegemessageExample();
           example.createCriteria().andIsAgreeEqualTo(1).andNameLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<Collegemessage> list = collegemessageService.selectByExample(example);
           for(Collegemessage ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getName());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(11+"");
               ret.addFindMsg(c);
           }
       }else if("12".equals(type)){
           BankExample example = new BankExample();
           example.createCriteria().andIsAgreeEqualTo(1).andBankNameLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<Bank> list = bankService.selectByExample(example);
           for(Bank ex :list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getBankName());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(12+"");
               ret.addFindMsg(c);
           }
       }else if("13".equals(type)){
           ApplyProjectExample example = new ApplyProjectExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ApplyProject> list = applyProjectService.selectByExample(example);
           for(ApplyProject ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(13+"");
               ret.addFindMsg(c);
           }           
       }else if("14".equals(type)){
           ServiceOrganizationExample example = new ServiceOrganizationExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTypeEqualTo("运营机构").andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
           for(ServiceOrganization ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(14+"");
               ret.addFindMsg(c);
           }
       }else if("15".equals(type)){
           ServiceOrganizationExample example = new ServiceOrganizationExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTypeEqualTo("法律服务").andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
           for(ServiceOrganization ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(15+"");
               ret.addFindMsg(c);
           }
       }else if("16".equals(type)){
           ServiceOrganizationExample example = new ServiceOrganizationExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTypeEqualTo("财会服务").andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
           for(ServiceOrganization ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(16+"");
               ret.addFindMsg(c);
           }
       }else if("17".equals(type)){
           ServiceOrganizationExample example = new ServiceOrganizationExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTypeEqualTo("知识产权").andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
           for(ServiceOrganization ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(17+"");
               ret.addFindMsg(c);
           }
       }else if("18".equals(type)){
           ServiceOrganizationExample example = new ServiceOrganizationExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTypeEqualTo("管理咨询").andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
           for(ServiceOrganization ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(18+"");
               ret.addFindMsg(c);
           }
       }else if("19".equals(type)){
           ServiceOrganizationExample example = new ServiceOrganizationExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTypeEqualTo("其它").andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
           for(ServiceOrganization ex : list){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(19+"");
               ret.addFindMsg(c);
           }
       }else if(type.equals("20")){
           AbilityExample example = new AbilityExample();
           example.createCriteria().andIsAgreeEqualTo(1).andTitleLike("%"+name+"%");
           example.setOrderByClause("create_time desc");
           List<Ability> abilityList = abilityService.selectByExample(example);
           for(Ability ex : abilityList){
               FindMsg.Builder c = FindMsg.newBuilder();
               c.setId(ex.getId());
               c.setTitle(ex.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
               c.setType(20+"");
               ret.addFindMsg(c);
           }
       }
       
       
       return ret;
   }
   
   /**
    * 删除消息列表
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MDelMsg", isLogin = true)
   public MRet.Builder DelMsg(String id)throws Exception{
       int result = userNotifyService.deleteByPrimaryKey(id);
       MRet.Builder c = MRet.newBuilder();
       if(result==0){
           c.setCode(-1);
           c.setMsg("删除失败...");
       }else if(result == 1){
           c.setCode(1);
           c.setMsg("删除成功...");
       }
       return c;
   }
   
   /**
    * 查看企业入驻信息
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MCheckEnterCompany", isLogin = false)
   public CompanyRegisterNewdetailList.Builder CheckEnterCompany(String id)throws Exception{
       CompanyRegisterNewdetailList.Builder ret = CompanyRegisterNewdetailList.newBuilder(); 
       
       Map<String, Object> map = new HashMap<String ,Object>();
       map.put("id", id);
       List<CompanyRegisterNewEx> list = companyRegisterNewService.selectAppList(map);
       if(list.isEmpty()){
           throw new MobException(MZchError.HAVE_NO_ZAITI_MSG);
       }
       
       /*CompanyRegisterNewEx sumData = companyRegisterNewService.selectSum(map);*/
       for(CompanyRegisterNewEx ex : list){
           CompanyRegisterNewdetail.Builder c = CompanyRegisterNewdetail.newBuilder();
           c.setCompanyName(ex.getCompanyName());
           c.setType(ex.getCyTypeName());
           c.setArea(ex.getArea());
           c.setPeople(ex.getPepole());
           /*c.setIncome(ex.getIncome());
           c.setIncomeLastYear(ex.getIncomeLastYear());*/
           c.setZaiti(ex.getZaitiName());
           c.setBeginTime(DateUtil.dateToStr(ex.getBeginTime()));
           c.setEndTime(DateUtil.dateToStr(ex.getEndTime()));
           c.setShudi(ex.getShudi());
           ret.addCompanyRegisterNewdetail(c);
           /*ret.setIncomeTotal(ex.getSumImcome());
           ret.setIncomeTotalLastYear(ex.getIncomeTotalLastYear());*/
       }       
       ret.setBeginTime(DateUtil.dateToStr(list.get(0).getBeginTime()).substring(0, 10));
       ret.setEndTime(DateUtil.dateToStr(list.get(0).getEndTime()).substring(0, 10));
       /*ret.setIncomeTotal(sumData.getSumImcome());
       ret.setIncomeTotalLastYear(sumData.getSumIncomeLastYear());*/
       return ret;
       
   }
   
   /**
    * 我要入驻
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MCheckNumber", isLogin = false)
   public JSONObject MCheckNumber(String id)throws Exception{
       JSONObject jsonObject = new JSONObject();
       jsonObject.put("way", "常州市钟楼区创新创业服务中心");
       jsonObject.put("address", "西横街6号 ");
       jsonObject.put("phone1", "0519-86628177");
       jsonObject.put("phone2", "0519-86628178");
       jsonObject.put("phone3", "13861175535");
       jsonObject.put("email", "466513259@qq.com");
       jsonObject.put("name", "杨国兴");
       return jsonObject;
       
   }
   
   /**
    * 政策列表
    * @param deptno
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MPolicyList", isLogin = false, isPage = true)
   public PolicydetailList.Builder PolicyList(String deptno,
                                              Integer page, 
                                              Integer limit, 
                                              String name,
                                              String kind)throws Exception{
       PaginationSupport.byPage(page, limit, false);
       PolicyExample example = new PolicyExample();
       Criteria criteria = example.createCriteria().andIsAgreeEqualTo(1);     
       if(StringUtils.isNotBlank(deptno)){
           criteria.andDeptnoEqualTo(Integer.parseInt(deptno));
       }
       if(name!=null){
           criteria.andTitleLike("%"+name+"%");
       }
       if(kind!=null){
           criteria.andKindEqualTo(kind);
       }
       example.setOrderByClause("publish_time desc,create_time desc");
       List<Policy> list = policyService.selectByExample(example);
       PolicydetailList.Builder ret = PolicydetailList.newBuilder();
       for(Policy ex : list){
           Policydetail.Builder c = Policydetail.newBuilder();
           c.setId(ex.getId());
           c.setTitle(ex.getTitle());
           c.setImages(ex.getImage());
           c.setType(ex.getType().toString());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setContent(ex.getContent());
           ret.addPolicydetail(c);
       }
       return ret;
   }
   
   /**
    * 政策详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MPolicyDetail", isLogin = false)
   public Policydetail.Builder PolicyDetail(String id)throws Exception{
       if (StringUtils.isBlank(id)) throw new MobException("id");
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("id", id);
       
       PolicyExample example = new PolicyExample();
       example.createCriteria().andIdEqualTo(id);
       List<Policy> list = policyService.selectByExample(example);
       if(list.size()==0){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       
       PolicyEx ex = policyService.selectAppDetail(map);
       if(ex==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       Policydetail.Builder c = Policydetail.newBuilder();
       c.setTitle(ex.getTitle());
       c.setUserName(ex.getNickName());
       c.setDeptName(ex.getDeptName());
       c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
       c.setContent(ex.getContent());
       c.setImages(ex.getImage());
       return c;
   }
   
   @MobileMethod(methodno = "MAndroidUpdate", isLogin = false)
   public JSONObject AndroidUpdate()throws Exception{
       JSONObject obj = new JSONObject();
       obj.put("verName", "钟创汇");
       obj.put("lastVerCode", 17);
       obj.put("apkUrl", "https://www.pgyer.com/0Vkg");
       obj.put("updateContent", "1、修复已知bug\n2、版本升为V1.5");  
       return obj;
   }
   
   /**
    *我参加的活动
    * @param mobileInfo
    * @param deptno
    * @param page
    * @param limit
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MMyJoinAct", isLogin = true, isPage = true)
   public MyActivityList.Builder  MyActivityList(MobileInfo mobileInfo,
                                                     Integer page, 
                                                     Integer limit)throws Exception{
       PaginationSupport.byPage(page, limit, false);
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("user_id", mobileInfo.getUserid());
       List<MyActivityEx> list = myActivityService.selectAppList(map);
       MyActivityList.Builder ret = MyActivityList.newBuilder();
       for(MyActivityEx ex : list){
           MyActivityDetail.Builder c = MyActivityDetail.newBuilder();
           c.setName(ex.getActivityName());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setId(ex.getId());
           c.setImage(ex.getImage());
           ret.addMyActivityDetail(c);
       }
       return ret;
   }
   
   /**
    * 我参加的活动详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MMyJoinActDetail", isLogin = true)
   public MyActivityDetail.Builder MyActivityDetail(String id)throws Exception{
       MyActivityDetail.Builder c = MyActivityDetail.newBuilder();
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("id", id);
       MyActivityEx ex = myActivityService.selectDetail(map);
       c.setActivityName(ex.getActivityName());
       c.setUserId(ex.getNickName());
       c.setCreateTime(ex.getActCreateTime());
       c.setActivityType(ex.getActivityTypeName());
       c.setContent(ex.getContent());
       c.setTyname(ex.getTyname());
       c.setTycompany(ex.getTycompany());
       c.setTyjob(ex.getTyjob());
       c.setZyly(ex.getZyly());
       c.setJob(ex.getJob());
       c.setNumber(ex.getNumber().toString());
       c.setCompany(ex.getCompany());
       c.setPhone(ex.getPhone());
       c.setActivityTime(ex.getActivityTime());
       c.setArea(ex.getArea());
       c.setImage(ex.getImage());
       if(ex.getName()!=null){
           c.setName(ex.getName());
       }else{
           c.setName(""); 
       }
       
       
       return c;
   }
   
   /**
    * 会议列表
    * @param mobileInfo
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MMeetingList", isLogin = false, isPage = true)
   public MeetingList.Builder MeetingList(MobileInfo mobileInfo, Integer page, Integer limit)throws Exception{
       PaginationSupport.byPage(page, limit, false);
       MeetingList.Builder ret = MeetingList.newBuilder();
       MeetingExample example = new MeetingExample();
       example.setOrderByClause("create_time desc");
       List<com.zch.dao.model.Meeting> list = meetingService.selectByExample(example);
       for(com.zch.dao.model.Meeting ex : list){
           Meeting.Builder c = Meeting.newBuilder(); 
           c.setTitle(ex.getTitle());
           c.setId(ex.getId());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           ret.addMeeting(c);
       }
       return ret;
   }
   
   /**
    * 会议详情(不连会议人员)
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MMeetingDetail", isLogin = false)
   public Meeting.Builder MeetingDetail(String id)throws Exception{
       Meeting.Builder c = Meeting.newBuilder();
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("id", id);
       List<com.zch.daoEx.model.MeetingEx> list = meetingService.selectAppList(map);
       for(com.zch.daoEx.model.MeetingEx ex : list){
           c.setTitle(ex.getTitle());
           c.setUser(ex.getNickName());
           c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
           c.setJoinTime(DateUtil.dateToStr(ex.getJoinTime()));
           c.setArea(ex.getArea());
           c.setContent(ex.getContent());
       }
       return c;
   }
   
   /**
    * 会议详情(参加会议人员)
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MMeetingJoinUsers", isLogin = false)
   public MeetingJoinUserList.Builder MeetingJoinUser(String id)throws Exception{
       MeetingJoinUserList.Builder ret = MeetingJoinUserList.newBuilder();      
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("id", id);
       List<com.zch.daoEx.model.MeetingJoinUserEx> list = meetingJoinUserService.selectAppList(map);
       for(com.zch.daoEx.model.MeetingJoinUserEx ex : list){
           MeetingJoinUser.Builder c = MeetingJoinUser.newBuilder();
           c.setId(ex.getId());
           c.setDeptName(ex.getDeptName());
           c.setAccount(ex.getAccount());
           c.setUserNickName(ex.getNickName());
           ret.addMeetingJoinUser(c);
       }
       return ret;
   }
   
   
   /**
    * 我参加的会议
    * @param mobileInfo
    * @param page
    * @param limit
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MMyMeeting", isLogin = true, isPage = true)
   public MeetingList.Builder  MyMeeting(MobileInfo mobileInfo,
                                     Integer page, 
                                     Integer limit)throws Exception{
       PaginationSupport.byPage(page, limit, false);
       MeetingList.Builder ret = MeetingList.newBuilder();
       MeetingJoinUserExample example = new MeetingJoinUserExample();
       example.createCriteria().andJoinUserEqualTo(mobileInfo.getUserid());
       List<com.zch.dao.model.Meeting> lists = new ArrayList<com.zch.dao.model.Meeting>();
       List<com.zch.dao.model.MeetingJoinUser> list = meetingJoinUserService.selectByExample(example);
       for(com.zch.dao.model.MeetingJoinUser ex : list){
           ex.getMeetingId();
           
           com.zch.dao.model.MeetingExample example2 = new com.zch.dao.model.MeetingExample();
           example2.createCriteria().andIdEqualTo(ex.getMeetingId());
           
           List<com.zch.dao.model.Meeting> list2 = meetingService.selectByExample(example2);
           for(com.zch.dao.model.Meeting ex2 : list2){
               Meeting.Builder c = Meeting.newBuilder();
               c.setId(ex2.getId());
               c.setTitle(ex2.getTitle());
               c.setCreateTime(DateUtil.dateToStr(ex2.getCreateTime()));
               ret.addMeeting(c);
           }
           
       }
       return ret;
   }
   
   /**
    * 人才项目列表
    * @param page
    * @param limit
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MAbilityList", isLogin = false, isPage = true)
   public AbilityDetailList.Builder MAbilityList(Integer page, 
                                                 Integer limit)throws Exception{
       PaginationSupport.byPage(page, limit, false);
       AbilityDetailList.Builder ret = AbilityDetailList.newBuilder();
       AbilityExample example = new AbilityExample();
       example.createCriteria().andIsAgreeEqualTo(1);
       example.setOrderByClause("create_time desc");
       List<Ability> list = abilityService.selectByExample(example);
       for(Ability ex : list){
           AbilityDetail.Builder c = AbilityDetail.newBuilder();
           c.setId(ex.getId());
           c.setTitle(ex.getTitle());
           ret.addAbilityDetail(c);
       }
       return ret;
   }
   
   /**
    * 人才项目详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MAbilityDetail", isLogin = false, isPage = false)
   public AbilityDetail.Builder MAbilityDetail(String id)throws Exception{
       AbilityExample example = new AbilityExample();
       example.createCriteria().andIdEqualTo(id);
       example.setOrderByClause("create_time desc");
       List<Ability> list = abilityService.selectByExample(example);
       Ability ex = list.get(0);
       if(ex==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       AbilityDetail.Builder c = AbilityDetail.newBuilder();
       c.setId(ex.getId());
       c.setTitle(ex.getTitle());
       c.setProjectArea(ex.getProjectArea());
       c.setMessage(ex.getMessage());
       c.setPersonMessage(ex.getPersonMessage());
       c.setProjectState(ex.getProjectState());
       c.setTeamWorkXq(ex.getTeamWorkXq());

    return c;    
   }
   
   /**
    * 人才项目联系方式
    * @return
    */
   @MobileMethod(methodno = "MAbilityTel", isLogin = false, isPage = false)
   public JSONObject MAbilityTelArray(){
       JSONObject object = new JSONObject();
       object.put("name", "丁文");
       object.put("tel", "18667005112");
       object.put("e_mail", "1392596674@qq.com");
       object.put("place", "创新创业服务中心");
       object.put("phone1", "0519-86628178");
       object.put("phone2", "0519-86628177");
       return object;
   }
   
   /**
    * 服务机构列表
    * type1:运营机构  2法律服务  3财会服务  4知识产权  5管理咨询  6其它
    */
   @MobileMethod(methodno = "MServiceOrganizationList", isLogin = false)
   public ServiceOrganizationList.Builder MServiceOrganizationList(String type)throws Exception{
       ServiceOrganizationList.Builder ret = ServiceOrganizationList.newBuilder();
       ServiceOrganizationExample example = new ServiceOrganizationExample();
       example.setOrderByClause("create_time desc");
       com.zch.dao.model.ServiceOrganizationExample.Criteria criteria = example.createCriteria().andIsAgreeEqualTo(1);       
       if("1".equals(type)){
           criteria.andTypeEqualTo("运营机构");           
       }else if("2".equals(type)){
           criteria.andTypeEqualTo("法律服务");
       }else if("3".equals(type)){
           criteria.andTypeEqualTo("财会服务");
       }else if("4".equals(type)){
           criteria.andTypeEqualTo("知识产权");
       }else if("5".equals(type)){
           criteria.andTypeEqualTo("管理咨询");
       }else if("6".equals(type)){
           criteria.andTypeEqualTo("其它");
       }else{
           throw new MobException("找不到该板块...");
       }
       List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
       for(ServiceOrganization ex : list){
           ServiceOrganizationDetail.Builder c = ServiceOrganizationDetail.newBuilder();
           c.setId(ex.getId());
           c.setTitle(ex.getTitle());
           ret.addServiceOrganizationDetail(c);
       }
       return ret;
   }
   
   /**
    * 机构详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MServiceOrganizationDetail", isLogin = false)
   public ServiceOrganizationDetail.Builder ServiceOrganizationDetail(String id)throws Exception{
       ServiceOrganizationDetail.Builder c = ServiceOrganizationDetail.newBuilder();
       ServiceOrganizationExample example = new ServiceOrganizationExample();
       example.createCriteria().andIdEqualTo(id);
       List<ServiceOrganization> list = serviceOrganizationService.selectByExample(example);
       ServiceOrganization ex = list.get(0);
       if(ex==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       c.setTitle(ex.getTitle());
       c.setCompanyZz(ex.getCompanyZz());
       c.setServiceContent(ex.getServiceContent());
       c.setOrganizationMsg(ex.getOrganizationMsg());
       return c;
   }
   
   /**
    * 机构详情--我要联系
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MServiceOrganizationTel", isLogin = false)
   public JSONObject object()throws Exception{
       JSONObject object = new JSONObject();
       object.put("name", "张宝儒");
       object.put("tel", "13775075917");
       object.put("e_mail", "408379819@qq.com");
       object.put("phone1", "0519-86628178");
       object.put("phone2", "0519-86628177");
    return object;     
   }
   
   /**
    * type
    * 申报项目列表
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MApplyProjectList", isLogin = false)
   public ApplyProjectList.Builder ApplyProjectList(String type)throws Exception{
       ApplyProjectExample example = new ApplyProjectExample();
       com.zch.dao.model.ApplyProjectExample.Criteria criteria = example.createCriteria().andIsAgreeEqualTo(1);      
       example.setOrderByClause("create_time desc");
       if("发改".equals(type)){
           criteria.andDeptEqualTo("发改");
       }else if("经信".equals(type)){
           criteria.andDeptEqualTo("经信");
       }else if("科技".equals(type)){
           criteria.andDeptEqualTo("科技");
       }else if("商务".equals(type)){
           criteria.andDeptEqualTo("商务");
       }else if("人才".equals(type)){
           criteria.andDeptEqualTo("人才");
       }else if("人社".equals(type)){
           criteria.andDeptEqualTo("人社");
       }else if("团委".equals(type)){
           criteria.andDeptEqualTo("团委");
       }else if("科协".equals(type)){
           criteria.andDeptEqualTo("科协");
       }else if("工会".equals(type)){
           criteria.andDeptEqualTo("工会");
       }else if("金融".equals(type)){
           criteria.andDeptEqualTo("金融");
       }else if("其它".equals(type)){
           criteria.andDeptEqualTo("其它");
       }
      List<ApplyProject> list =  applyProjectService.selectByExample(example);
      
      ApplyProjectList.Builder ret = ApplyProjectList.newBuilder();
      for(ApplyProject ex : list){
          ApplyProjectDetail.Builder c = ApplyProjectDetail.newBuilder();
          c.setId(ex.getId());
          c.setTitle(ex.getTitle());
          c.setCreateTime(DateUtil.dateToStr(ex.getCreateTime()));
          ret.addApplyProjectDetail(c);
      }
      return ret;
   }
   
   /**
    * 申报项目详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MApplyProjectDetail", isLogin = false)
   public ApplyProjectDetail.Builder ApplyProjectDetail(String id)throws Exception{
       ApplyProjectExample example = new ApplyProjectExample();
       example.createCriteria().andIdEqualTo(id);
       List<ApplyProject> list =  applyProjectService.selectByExample(example);
       ApplyProject applyProject = list.get(0);
       if(applyProject==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       ApplyProjectDetail.Builder c = ApplyProjectDetail.newBuilder();
       c.setTitle(applyProject.getTitle());
       c.setDept(applyProject.getDept());
       c.setMessage(applyProject.getMessage());
       c.setApplyEndTime(DateUtil.dateToStr(applyProject.getApplyEndTime()));
       c.setApplyUrl(applyProject.getApplyUrl());
       return c;
   }
   
   /**
    * 银行金融列表
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MBankList", isLogin = false)
   public BankList.Builder BankList()throws Exception{
       BankList.Builder ret = BankList.newBuilder();
       BankExample example = new BankExample();
       example.createCriteria().andIsAgreeEqualTo(1);
       example.setOrderByClause("create_time desc");
       List<Bank> list = bankService.selectByExample(example);
       for(Bank ex : list){
           BankDetail.Builder c = BankDetail.newBuilder();
           c.setId(ex.getId());
           c.setBankName(ex.getBankName());
           ret.addBankDetail(c);
       }
       return ret;
   }
   
   /**
    * 银行金融详情
    * @param id
    * @return
    * @throws Exception
    */
   @MobileMethod(methodno = "MBankDetail", isLogin = false)
   public BankDetail.Builder BankDetail(String id)throws Exception{
       BankDetail.Builder c = BankDetail.newBuilder();
       BankExample example = new BankExample();
       example.createCriteria().andIdEqualTo(id);
       List<Bank> list = bankService.selectByExample(example);
       Bank bank = list.get(0);
       if(bank==null){
           throw new MobException(MZchError.CONTENT_NOT_EXIST);
       }
       c.setBankName(bank.getBankName());
       c.setProductName(bank.getProductName());
       return c;
   }
}
